package com.hiof.connection;

import android.os.Handler;
import android.os.Message;
import android.widget.Toast;
import com.hiof.Configuration;
import com.hiof.menus.NavigationMenu;

/**
 * Created with IntelliJ IDEA.
 * User: manish
 * Date: 4/12/12
 * Time: 2:30 PM
 * To change this template use File | Settings | File Templates.
 */
public class DataReceiveHandler extends Handler {
    @Override
    public void handleMessage(Message msg) {
        if(msg.getData()!=null && !String.valueOf(msg.getData().get("message")).equals("null")){
            Toast.makeText(Configuration.getInstance().getCurrentContext(), msg.getData().get("message").toString(), Toast.LENGTH_LONG);
            if(msg.getData().get("message").equals("next")){
                NavigationMenu.getInstance().next();
            }else if(msg.getData().get("message").equals("previous")){
                NavigationMenu.getInstance().previous();
            }
            if(msg.getData().get("message").equals("select")){
                NavigationMenu.getInstance().select();
            }
            if(msg.getData().get("message").equals("cancel")){
                NavigationMenu.getInstance().cancel();
            }
        }else{
            Toast.makeText(Configuration.getInstance().getCurrentContext(), "Error:",Toast.LENGTH_SHORT).show();
        }
    }
}
